<h1>Buscar Atendimento</h1>
<center>
    <div class="pesquisa">
        <form action="<?php echo $this->baseUrl() ?>/atendimento/listar" method="post">
            <ul>
                <li>
                    <p>
                        <label>Nome Assistido</label>
                        <input name="assistido" type="text" class="big" title="Digite aqui o nome para busca" value="<?php echo $this->assistido ?>" />
                    </p>
                    <!--
                    <p>
                        <label>Nome Parte Contrária</label>
                        <input name="parteContraria" type="text" class="big" title="Digite aqui o nome para busca" value="" />
                    </p>
                     -->
                    <p>
                        <label>Status</label>
                        <select name="status" class="medium" title="Selecione aqui o Status para Busca">
                           <option value="">Selecione</option>
                           <option value="A">Aberto</option>
                           <option value="E">Em Andamento</option>
                           <option value="C">Concluído</option>
                        </select>
                    </p>
                    <p>
                        <label>Data Início</label>
                        <input id="datepicker_1" type="text" name="inicio" value="" />
                    </p>
                    <p>
                        <label>Data Fim</label>
                        <input id="datepicker_2" type="text" name="fim" value="" />
                    </p>
                </li>
            </ul>
            <div class="navegacao">
                <input type="button" value="Novo" class="small" onclick="window.location='<?php echo $this->baseUrl()?>/atendimento/'" target="main" />
                <input type="submit" value="Buscar" class="small" />
            </div>
        </form>
    </div>

    <?php if ($this->atendimentos) : ?>
    <div class="pesquisa">
        <table class="listagem">
            <thead>
                <tr>
                    <th>Código</th>
                    <th>Assistido</th>
                    <th>Status</th>
                    <th>Data</th>
                    <th>Edição</th>
                </tr>
            </thead>
            <?php foreach ($this->atendimentos as $item) : ?>
                <tr>
                    <td><?php echo $item->id_atendimento ?></td>
                    <td><?php echo $item->ds_nome ?></td>
                    <td><?php echo $this->statusAtendimento($item->st_atendimento) ?></td>
                    <td><?php echo $this->data($item->dt_atendimento) ?></td>
                    <td>
                    	<a href="atendimento/index/id/<?php echo $item->id_atendimento?>">
                    		<img src="img/editar.jpg" title="Editar">
                    	</a>
                    	<img src="img/excluir.jpg" title="Excluir">
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>
    </div>
    <?php endif; ?>

</center>

<script>
$(function() {
    var dates = $("#datepicker_1, #datepicker_2").datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        numberOfMonths: 1,
        onSelect: function( selectedDate ) {
            var option = this.id == "datepicker_1" ? "minDate" : "maxDate",
                instance = $( this ).data( "datepicker" ),
                date = $.datepicker.parseDate(
                    instance.settings.dateFormat ||
                    $.datepicker._defaults.dateFormat,
                    selectedDate, instance.settings);
            dates.not( this ).datepicker("option", option, date);
        }
    });
});
</script>